﻿Module Mvariabili
    Public primoavvio As Integer = 1
    Public commesse As System.Collections.ObjectModel.ReadOnlyCollection(Of String)
    Public rcommesse As New ArrayList
    Public stread As System.IO.StreamReader
    Public stwrite As System.IO.StreamWriter
    Public cliente As String
    Public odp As String
    Public quantita As String
    Public colore As String
    Public posizionex As Integer = 20
    Public posizioney As Integer = 75
    Public htesto As Integer = 25



    Sub leggi_impostazioni()
        If System.IO.File.Exists(Application.StartupPath & "\commesse.txt") Then
            stread = New System.IO.StreamReader(Application.StartupPath & "\commesse.txt")
            While Not stread.EndOfStream
                Dim riga = stread.ReadLine
                If riga <> "" Then
                    rcommesse.Add(riga)
                End If

            End While

            stread.Close()
        End If
    End Sub

    Sub salva_impostazioni()

        stwrite = New System.IO.StreamWriter(Application.StartupPath & "\commesse.txt")
        If commesse Is Nothing Then
        Else

            For Each riga In commesse
                stwrite.WriteLine(riga)
            Next
        End If

        stwrite.Close()
        leggi_impostazioni()

    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="FILE_IMPOSTAZIONI"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Function LEGGI_IMP(ByVal FILE_IMPOSTAZIONI As String) As ArrayList
        Dim ARRAYLIST As New ArrayList

        stread = New System.IO.StreamReader(Application.StartupPath & "\" & FILE_IMPOSTAZIONI & ".txt")
        While Not stread.EndOfStream
            Dim riga = stread.ReadLine
            If riga <> "" Then
                ARRAYLIST.Add(riga)
            End If

        End While

        stread.Close()

        Return ARRAYLIST
    End Function
End Module
